/*----------------------------------------------------------------------
  - File name      : pid.h
  - Author         : Liu Chao
  - Update date    : 2020-07-14                   
  -	Copyright      : Gevico Electronic studio   
  - Module comments: 
-----------------------------------------------------------------------*/
  
#ifndef __PID_H
#define __PID_H

/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/

#include "main.h"
#include "tim.h"

/*-----------------------------------------------------------------------
|                                 DATA                                  |
-----------------------------------------------------------------------*/

typedef struct
{
  double Uv; //User settings value
  double Sv; //Sensor measured value

  double Kp; //proportionality coefficient
  double ST; //Sampling cycle time  Time unit: ms
  double Ti; //Integral time        Time unit: ms
  double Td; //Derivative time      Time unit: ms

  double Ek;  //This deviation
  double Ek_1;//Last deviation
  double Ek_2;//Last last deviation

  double Outx; //Output constant
  
  double Out;  //Output results
}PID;


/*-----------------------------------------------------------------------
|                             API FUNCTION                              |
-----------------------------------------------------------------------*/

extern PID CTB_PID; //Control the ball of PID

void PID_Init(void);
void PID_Calc(float SXv,float SYv);
void pid_task_handler(void);

#endif /*__ pid_H */

/*-------END OF FLIE--------(C) COPYRIGHT Gevico Electronics-----------*/
